// pages/yjmx/yjmx.js
var common = require("../../utils/public.js") //引入public.js脚本
var api = require("../../utils/api");
var time = require("../../utils/time.js");
Page({

  /**
   * 页面的初始数据
   */
  data: {
    date: '',
    list:[],
    msg:{},
    num:1,
  },
  bindDateChange: function (e) {
    let that=this
    that.setData({
      date: e.detail.value
    })
    api.brokerageList({
      orderDateType: '',
      orderDate: e.detail.value,
      page: {
        
      }
    }).then(res => {
      if (res.result) {
        that.setData({
          list: res.object.records,
        })
      } else {
        wx.showToast({
          title: '网络异常',
          icon: "none"
        })
      }
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let that=this
    let now = Date.now()
    that.setData({
      date: time.formatTimeTwo(now, 'Y-M'),
    })
    api.brokerageList({
      page: {},
      orderDate:'',
      orderDateType: "1"
    }).then(res => {
      if (res.result){
        that.setData({
          list: res.object.records,
          msg:res.body.msg
        })
      }else{
        wx.showToast({
          title: '网络异常',
          icon:"none"
        })
      }
    })
  },
  navTap(e){
    let that = this
    let num = e.currentTarget.dataset.num+''
    that.setData({
      num
    })
    api.brokerageList({
      orderDateType: num != '4' ? num : '',
      orderDate: num == "4" ? that.data.date : '',
      page: {
        
      }
    }).then(res => {
      if (res.result) {
        that.setData({
          list: res.object.records
        })
      } else {
        wx.showToast({
          title: '网络异常',
          icon: "none"
        })
      }
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})